/**
 * 
 */
package com.cqcis.uip.base.framework.core.impl;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import com.cqcis.uip.base.framework.core.Endpoint;
import com.cqcis.uip.base.framework.core.Route;

/**
 * @author huangmy
 *
 */
public class RouteImpl implements Route, Serializable {
	private static final long serialVersionUID = 1L;
	private Endpoint from;  /*源端点*/
    private Endpoint to;    /*目标端点*/
    private List<Endpoint> fromTrace = Collections.synchronizedList(new ArrayList<Endpoint>());
    private List<Endpoint> toTrace = Collections.synchronizedList(new ArrayList<Endpoint>());
    
	public Endpoint from() {		
		return from;
	}

	public void from(Endpoint from) {
		this.from = from;
		this.fromTrace.add(from);
	}

	public Endpoint to() {
		return to;
	}

	public void to(Endpoint to) {
		this.to = to;
		this.toTrace.add(to);
	}

	public List<Endpoint> traceFrom() {		
		return fromTrace;
	}

	public List<Endpoint> traceTo() {		
		return toTrace;
	}
	
	@Override
	public String toString() {
		StringBuffer buffer = new StringBuffer();
		buffer.append("{Route>>> from: ").append(from)
		      .append(", to: ").append(to)
		      .append(";")
		      .append(" traceFrom: ").append(fromTrace)
		      .append("; traceTo: ").append(toTrace)
		      .append(";}");
		
		return buffer.toString();
	}	
}
